<!--
* description: 支给件关系查询-明细
-->
<template>
  <section class="editCarBrand">
    <el-dialog
      v-dialogDrag
      :close-on-click-modal="false"
      title="支给件明细查询"
      :append-to-body="true"
      :visible.sync="curPopupsVisible"
      @close="sendCode"
      width="1000px"
    >
      <dialogHeader slot="title" title="支给件明细查询" :styleType="$store.state.app.dialogType"></dialogHeader>
      <div class="filter-container filter-params">
        <el-row :gutter="26">
          <component
            v-for="comp in tableComponents.filter(o => o.isMust === true)"
            :ref="comp.isRequire ? comp.isRequire+ comp.compKey : comp.compKey"
            :validrule="comp.validrule"
            :key="comp.compKey"
            :codeField="comp.codeField"
            :textField="comp.textField"
            :popupsKey="comp.compKey"
            :is="comp.component"
            :code="formField[comp.codeField]"
            :text="formField[comp.textField]"
            @changeCode="getComponentCode"
            @focusCode="getFocusCode"
            :disabled="comp.disabled"
            :isRequire="comp.isRequire"
            :span="comp.span || 8"
            :isMul="comp.isMul"
            :labelName="comp.labelName"
            :readonly="comp.readonly"
            :showPlaceholder="comp.showPlaceholder"
            :dateOptionsType="comp.dateOptionsType"
            :options="comp.options"
            :isInput="comp.isInput"
          />
        </el-row>
        <!-- 表格 -->
        <el-row :gutter="34" style="margin-bottom:5px;">
          <el-col :span="24">
            <el-table
              :data="tableData"
              style="width: 100%"
              height="300"
              border
              v-loading="listLoading"
            >
              <el-table-column label="序号" width="60" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.$index + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column label="支给件备件编号" prop="PART_NO" align="center"></el-table-column>
              <el-table-column label="支给件备件名称" prop="PART_NAME" align="center"></el-table-column>
              <el-table-column label="支给件备件数量" prop="PART_QTY" align="center"></el-table-column>
            </el-table>
          </el-col>
        </el-row>
        <!-- 表格 -->
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button
          v-for="comp in tableButtons"
          :key="comp.compKey"
          :type="comp.type"
          @click="comp.clickEvent"
        >{{comp.text}}</el-button>
      </div>
    </el-dialog>
  </section>
</template>
<script>
import { formMixins } from "@/components/wms/mixins/formMixins";
import request from "@/utils/request";
export default {
  // 组件混入对象
  mixins: [formMixins],
  components: {
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey2",
          type: "",
          size: "small",
          clickEvent: () => this.close("1"),
          text: "返回"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        {
          compKey: "edit_compKey1",
          labelName: "总成件编号",
          codeField: "PART_NO",
          textField: "PART_NO",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true,
          readonly: true
        },
        {
          compKey: "edit_compKey2",
          labelName: "总成件数量",
          codeField: "PART_QTY",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true,
          readonly: true
        },
        {
          compKey: "edit_compKey3",
          labelName: "备注",
          codeField: "REMARK",
          component: () => import("@/components/wms/textareaInput"),
          type: "inputText",
          span: 24,
          isMust: true,
          readonly: true
        }
      ],
      // 表单数据（无需赋值，由混入对象赋值）
      formField: {
        ASSEMBLY_ID: "",
        PART_NO: "",
        PART_QTY: "",
        REMARK: ""
      },
      //表格数据
      tableData: [],
      // 表格加载字段
      listLoading: false
    };
  },
  methods: {
    onCreated() {
      if (this.curPopupsVisible) {
        this.listLoading = true;
        request({
          url: "/mp/wm/vl/warehouse/assembly/queryAssemblyD.do",
          method: "post",
          data: {
            ASSEMBLY_ID: this.formField.ASSEMBLY_ID
          }
        })
          .then(res => {
            this.listLoading = false;
            if (res.result === "1") {
              if (res.listRow && res.listRow.length > 0) {
                this.tableData = res.listRow;
              }
            } else {
              if (res.msg || res.debugMsg) {
                this.$message({
                  message: res.debugMsg ? res.debugMsg : res.msg,
                  uration: 2000
                });
              }
            }
          })
          .catch(err => {
            console.info(err);
            this.listLoading = false;
          });
      }
    }
  }
};
</script>
<style type="text/css" lang="scss" scoped>
.dialogTitle {
  text-align: left;
  overflow: hidden;
}
.dialogTitleButton {
  float: right;
}
/deep/ .tableTemplate .el-input__inner {
  border: none;
}
</style>